// @Desc: 定时任务
// @CreateTime: 2020/10/22
package corntask

import (
    // "github.com/robfig/cron/v3"
    mlog "mycrm.com/log"
    "github.com/robfig/cron/v3"
    "mycrm.com/controller/visit"
)

// 初始化定时任务
func InitCronTask() error {
    cronObj := cron.New()
    // 每小时统计一次
    _, err := cronObj.AddFunc("0 */1 * * ?", visit.StatisticsVisitByDay)
    if err != nil {
        mlog.Log.Error("cronObj.AddFunc is failed, err: ", err)
        return err
    }
    cronObj.Start()
    return nil
}